package me.ydq.core.sql;

import me.ydq.core.SqlSpec;
import me.ydq.misc.Fn;

import java.util.function.Supplier;

public interface SqlGreaterThan<T> {

    SqlSpec<T> gt(Fn<T, ?> fn, Object value);

    SqlSpec<T> gt(String rawColumn, Object value);

    default SqlSpec<T> gt(Supplier<Boolean> condition, Fn<T, ?> fn, Supplier<Object> valGet) {
        return gt(Boolean.TRUE.equals(condition.get()), fn, valGet);
    }

    default SqlSpec<T> gt(Supplier<Boolean> condition, Fn<T, ?> fn, Object val) {
        return gt(Boolean.TRUE.equals(condition.get()), fn, val);
    }

    default SqlSpec<T> gt(boolean condition, Fn<T, ?> fn, Supplier<Object> valGet) {
        return condition ? gt(fn, valGet.get()) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> gt(boolean condition, Fn<T, ?> fn, Object val) {
        return condition ? gt(fn, val) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> gt(Fn<T, ?> fn, Supplier<Object> valGet) {
        return gt(fn, valGet.get());
    }

    default SqlSpec<T> gt(Supplier<Boolean> condition, String rawColumn, Supplier<Object> valGet) {
        return gt(Boolean.TRUE.equals(condition.get()), rawColumn, valGet);
    }

    default SqlSpec<T> gt(Supplier<Boolean> condition, String rawColumn, Object val) {
        return gt(Boolean.TRUE.equals(condition.get()), rawColumn, val);
    }

    default SqlSpec<T> gt(boolean condition, String rawColumn, Supplier<Object> valGet) {
        return condition ? gt(rawColumn, valGet.get()) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> gt(boolean condition, String rawColumn, Object val) {
        return condition ? gt(rawColumn, val) : (SqlSpec<T>) this;
    }

    default SqlSpec<T> gt(String rawColumn, Supplier<Object> valGet) {
        return gt(rawColumn, valGet.get());
    }
}
